﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeMonkey.EditableObject.Core;
using WpfLib.Interfaces;

namespace CodeMonkey.EditableObject.ClassEx
{
    /// <summary>
    /// DataGrid的行编辑的数据源的基类
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public abstract class EditableEntityViewModel<TEntity> : EditableModelBase<TEntity>, IModelContained<TEntity>, ISelectableTwoStatus, IEditable
    {
        protected EditableEntityViewModel(TEntity model, bool canEdit = false)
            : base(model)
        {
            CanEdit = canEdit;
        }

        private bool canEdit = default(bool);
        /// <summary>
        /// 这个是否只读化很难一概而论
        /// </summary>
        public bool CanEdit
        {
            get { return canEdit; }
            set { Set("CanEdit", ref canEdit, value); }
        }

        private bool isSelected = default(bool);
        public bool IsSelected
        {
            get { return isSelected; }
            set { Set("IsSelected", ref isSelected, value); }
        }

        public virtual TEntity ModelContained { get { return ModelInstance; } }
    }
}
